<?php
namespace app\api\controller;
use app\common\model\orderdata\StorageAreaGoods;
use think\File;
use think\facade\Env;
use app\common\model\user\User as UserModel;
use app\common\model\company\Company;
use app\common\model\orderdata\Goods;
use app\common\model\power\Rolepower;
class Pubfun extends Base
{
	/**
	 * 用户登录后的公用方法
	 */
    public function initialize(){
		parent::initialize();
		self::is_login();
	}

	/**
	 * 获取目前可下单的商品清单
	 * @return [type] [description]
	 */
	public function getgoodlist(){
		$type = input('Type');
		$companyid = input('CompanyId');
		switch ($type) {
			case 'distware':
				Rolepower::powerguard('202002');
				$goodlist = Goods::getwarelist();
				break;
			default:
				$goodlist = Goods::getlist([],$companyid);
				break;
		}
		return myok($goodlist);
	}
	
	/**
	 * 判断账号是否登录
	 * @return boolean [description]
	 */
	private function is_login(){
		$data = UserModel::is_sessionlogin();
		if (!$data['code']) {
			$data['options'] = 'relogin';
			json($data)->send();
			exit;
		}
	}
}
